<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page import="org.openflashchart.Graph"%>
<%@page import="java.util.List"%>
<%@page import="com.ejoysoft.wlanyz.business.Flowanalysis"%>
<%@page import="java.util.ArrayList"%>
<%@ include file="../include/jsp/head.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@page import="java.text.DecimalFormat"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>饼图演示</title>
</head>
<body>
<%
    String  strStartTime = ParamUtil.getString(request,"strStartTime","");
    String  strEndTime = ParamUtil.getString(request,"strEndTime","");
    //System.out.println("UUUUUUUUUUUUUUUUU");
    String strCity = globa.city;
    String hotPot = globa.hotpot;
    double nummax = 0;
    String twhere = " where 1 = 1 ";
    if(!strCity.equals("")){
    twhere+=" and strcity = '"+ strCity +"' ";
    }
    if(!hotPot.equals("")){
    twhere+=" and strtown = '"+ hotPot +"' ";
    }
    if(strStartTime.equals(""))strStartTime = "1000-1-01";
    if(strEndTime.equals(""))strEndTime = "9999-12-30";
    twhere+=" and starttime between to_date('" + strStartTime + "','yyyy-MM-dd hh24.mi.ss') and to_date('" + strEndTime + "','yyyy-MM-dd hh24.mi.ss') ";
    Flowanalysis obj = new Flowanalysis(globa);
	Graph g = new Graph();
	List<String> data = new ArrayList<String>();
	List<String> labels = new ArrayList<String>();
	List<String> links = new ArrayList<String>();
	List<String> colors = new ArrayList<String>();
	
	int max = 100;
	double wlanFlow = obj.flowSum(twhere,"WLAN");
	double tdFlow = obj.flowSum(twhere,"TD");
	double gsmFlow = obj.flowSum(twhere,"GSM");
	double allFlow = wlanFlow+tdFlow+gsmFlow;
	String wlanRate = String.valueOf(wlanFlow/allFlow+0.005).substring(0,4);//四舍五入拿到字符串类型的比率
	String tdRate = String.valueOf(tdFlow/allFlow+0.005).substring(0,4);
	String gsmRate = String.valueOf(1-Double.parseDouble(wlanRate)-Double.parseDouble(tdRate)).substring(0,4);
		data.add(String.valueOf(wlanFlow));
		data.add(String.valueOf(tdFlow));
		data.add(String.valueOf(gsmFlow));
		labels.add("WLAN:"+ wlanRate);
		labels.add("TD:"+ tdRate);
		labels.add("GSM:"+ gsmRate);
		links.add("" );
	/*
	data.add(Double.toString(50));
	data.add(Double.toString(50));
	data.add(Double.toString(50));
	*/

	g.title("三网数据业务流量分析", "{font-size: 26px;}");
	g.pie(45, "#505050", "{font-size: 12px; color: #404040;}");
	g.pie_values(data, labels, links);
	colors.add("#d01f3c");
	colors.add("#356aa0");
	colors.add("#C79810");
	
	g.pie_slice_colours(colors);
	g.set_tool_tip("#val# ");
%>
<%=g.render()%>
</body>
</html>
<%@ include file="../include/jsp/footer.jsp"%>